﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class Menu_Default : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        UserPower.CheckAction((int)FreeHouse.Power.Actions.TMenu.List);
        Master.AddHRef = "../Menu/Add.aspx";
        if (!IsPostBack) BindData();
    }
    protected void back_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }

    protected void BindData()
    {
        DataSet ds = new FreeHouse.BLL.TMenu().GetList("parentMenuid=0 ");
        DataTable dt = ds.Tables[0].Clone();
        foreach (DataRow parentRow in ds.Tables[0].Rows)
        {
            dt.Rows.Add(parentRow.ItemArray);
            DataTable childMenu = new FreeHouse.BLL.TMenu().GetList("parentMenuId=" + parentRow["menuid"].ToString()).Tables[0];
            foreach (DataRow childRow in childMenu.Rows)
            {
                //string tag=childMenu.Rows.IndexOf(childRow)==childMenu.Rows.Count-1?"|_":"|-";
                childRow["MenuName"] = Server.HtmlDecode("&nbsp;&nbsp;&nbsp;&nbsp;") + childRow["MenuName"].ToString();
                dt.Rows.Add(childRow.ItemArray);
            }
        }
        gv.DataSource = dt.DefaultView;
        gv.DataBind();
    }
}
